﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using System.Text;
using Zatify.Domain.Data;

namespace Zatify.WebUI.Admin.HtmlHelpers
{
    public static class CategoryBreadCrumbsHelper
    {
        public static MvcHtmlString CategoryBreadCrumbs(this HtmlHelper html, Category category, Func<int, string> func, string delimeter)
        {
            var result = new StringBuilder();

            if (category.ParentId > 0)
                result.Append(CategoryBreadCrumbs(html, category.ParentCategory, func, "\\").ToString());

            var tagDiv = new TagBuilder("div");
            tagDiv.MergeAttribute("class", "diver");

            var tagSpan = new TagBuilder("span");
            tagSpan.InnerHtml = category.CategoryName;

            tagDiv.InnerHtml = tagSpan.ToString();

            result.Append(tagDiv.ToString());

            var tagSpanDelimeter = new TagBuilder("span");
            tagSpanDelimeter.InnerHtml = delimeter;
            tagSpanDelimeter.MergeAttribute("class", "delimeter");

            result.Append(tagSpanDelimeter.ToString());

            return MvcHtmlString.Create(result.ToString());
        }
    }
}